using System;
using UnityEngine;

namespace Prototype.JumpOverTheWorld
{
    public class MoveLeft : MonoBehaviour
    {
        public float speed = 30;
        public float leftBound = -5;
        private PlayerController playerControllerScript;

        private void Start()
        {
            playerControllerScript = FindObjectOfType<PlayerController>();
        }

        private void Update()
        {
            if(!playerControllerScript.gameOver)
            {
                transform.Translate(Time.deltaTime * speed * Vector3.left);
            }
            
            if(transform.position.x < leftBound && gameObject.CompareTag("Obstacle"))
            {
                Destroy(gameObject);
            }
        }
    }
}